#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "controllerstatus.h"
#include "sources/database.h"

int main(int argc, char *argv[])
{
    qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QGuiApplication app(argc, argv);

    ControllerStatus swmStatus;

    QQmlApplicationEngine engine;

    QString path = engine.offlineStorageDatabaseFilePath("ShoeWashingMachine");
    path.append(".sqlite");
    if (!createConnection(path))
        return EXIT_FAILURE;

    engine.rootContext()->setContextProperty("swmStatus",&swmStatus);
    engine.load(QUrl(QLatin1String("qrc:/main.qml")));
    if (engine.rootObjects().isEmpty())
        return -1;

    return app.exec();
}
